﻿using System;
using System.Net;
using System.Text;
using System.Windows;

namespace PushEmail.Common
{
    public class SystemConfigure
    {
        private static SystemConfigure _peConfigure = new SystemConfigure();
        private static string _pushRequestURI = "";

        public string pushRequestURI
        {
            get { return _pushRequestURI; }
            set { _pushRequestURI = value; }
        }

        private SystemConfigure()
        {
            
        }

        public string GetDeviceName()
        {
            return DeviceInfo.GetDeviceName();
        }

        public string GetManufacturer()
        {
            return DeviceInfo.GetManufacturer();
        }

        public string GetDeviceHardwareVersion()
        {
            return DeviceInfo.GetDeviceHardwareVersion();
        }

        public string GetDeviceUniqueID()
        {
            byte[] uniqID = DeviceInfo.GetDeviceUniqueID();
            if (uniqID != null)
            {
                return Encoding.UTF8.GetString(uniqID, 0, uniqID.Length);
            }

            return null;//"no DeviceUniqueID";
        }
        
        public static SystemConfigure Instance()
        {
            return _peConfigure;
        }

        public static Size GetScreenSize()
        {
            Size screenSize = new Size(0,0);
            try
            {
                int scale = Application.Current.Host.Content.ScaleFactor;
                switch (scale)
                {
                    case 100:   //WVGA
                        screenSize.Height = 800;
                        screenSize.Width = 480;
                        break;
                    case 150:   //720p
                        screenSize.Height = 1280;
                        screenSize.Width = 720;
                        break;
                    case 160:   //WXGA
                        screenSize.Height = 1280;
                        screenSize.Width = 768;
                        break;
                    default:
                        break;
                }
            }
            catch
            {
            }
            return screenSize;
        }
    }
}
